<script setup>
//watch监视响应式变化，作用跟vue2一样
/* vue2用法
data() {
  return {
    count: 0
  }
},
watch: {
  count(newVal, oldVal) {
    console.log('newVal', newVal)
    console.log('oldVal', oldVal)
  }
} */
//vue3用法
import { watch, ref } from 'vue'
const count = ref(0)
watch(count, (newVal, oldVal) => {
  console.log('newVal', newVal)
  console.log('oldVal', oldVal)
})
</script>

<template>
  <div>
    count: {{ count }}
  </div>
  <button @click="count++">count++</button>
</template>

<style lang="scss" scoped>

</style>
